
#import "UIView+extension.h"
#import <MBProgressHUD/MBProgressHUD.h>

@implementation UIView (extension)

- (void)showTipsView:(NSString *)tips
          afterDelay:(NSTimeInterval)delay
       completeBlock:(MBProgressHUDCompletionBlock)completeBlock
{
    if(tips.length == 0) {
        tips = @"网络异常";
    }
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
    hud.completionBlock = completeBlock;
    // Configure for text only and offset down
    hud.mode = MBProgressHUDModeText;
    hud.detailsLabel.text = tips;
    hud.detailsLabel.font = [UIFont systemFontOfSize:14.0f];
    hud.margin = 10.f;
    hud.removeFromSuperViewOnHide = YES;
    [hud hideAnimated:YES afterDelay:delay];
}

- (void)showTipsView:(NSString *)tips {
    [self showTipsView:tips afterDelay:2];
}

- (void)showTipsView:(NSString *)tips
          afterDelay:(NSTimeInterval)delay {
    [self showTipsView:tips afterDelay:delay completeBlock:nil];
}

@end
